package com.shadow.baiqun.delegate.common;

import com.alibaba.fastjson.JSONObject;

/**
 * @author zy
 * on 2018/7/7
 */
public class ResultConverter {
    public boolean isSucceed(String response) {
        try {
            JSONObject jsonObject = JSONObject.parseObject(response);
            int status = jsonObject.getInteger("status");
            if (status == 1) {
                return true;
            } else {
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

    }

    public int getCode(String response) {
        try {
            JSONObject jsonObject = JSONObject.parseObject(response);
            return jsonObject.getInteger("status");
        } catch (Exception e) {
            e.printStackTrace();
            return -1;
        }
    }

    public String getMsg(String response) {
        try {
            JSONObject jsonObject = JSONObject.parseObject(response);
            return jsonObject.getString("Msg");
        } catch (Exception e) {
            e.printStackTrace();
            return "系统错误";
        }
    }
}
